<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
<head>
<script src="http://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
</head>

<body>
<div class='input-group form-inline'>
<form action="">
<input type='text' class='form-control' style='width:30%;margin-bottom:2px;' name='one[]' placeholder='输入一级菜单'>
<input type='text' class='form-control' style='width:30%;margin-bottom:2px;' name='second[]' placeholder='请输入二级名字'> 
<input type='text' name='url[]'  class='form-control' style='width:30%;margin-bottom:2px;' placeholder='请输入二级菜单url'>

<input type='text' class='form-control' style='width:30%;margin-bottom:2px;' name='one[]' placeholder='输入一级菜单'>
<input type='text' class='form-control' style='width:30%;margin-bottom:2px;' name='second[]' placeholder='请输入二级名字'> 
<input type='text' name='url[]'  class='form-control' style='width:30%;margin-bottom:2px;' placeholder='请输入二级菜单url'>

<input type='text' class='form-control' style='width:30%;margin-bottom:2px;' name='one[]' placeholder='输入一级菜单'>
<input type='text' class='form-control' style='width:30%;margin-bottom:2px;' name='second[]' placeholder='请输入二级名字'> 
<input type='text' name='url[]'  class='form-control' style='width:30%;margin-bottom:2px;' placeholder='请输入二级菜单url'>
<button type="button" class="btn btn-block sub" onclick="getValue()">提交</button>
</div>
</form>
<script>
 $(function(){
	 var valArr = new Array;
		var valArr1 = new Array;
		var valArr2= new Array;
		$("input[name='one[]']").each(function(index, item){
               valArr[index] = $(this).val();
               var priv = valArr.join(',');
               alert(priv);
           });
		$("input[name='second[]']").each(function(index, item){
               valArr1[index] = $(this).val();
               var priv = valArr1.join(',');
               alert(priv);
           });
		$("input[name='url[]']").each(function(index, item){
               valArr2[index] = $(this).val();
               var priv = valArr2.join(',');
               alert(priv);
           });
     var view = new Object();
view ={
	"button":[
	{
		"name":valArr[0],
		"sub_button":[{
			"type":"view",
			"name":valArr1[0] ,
			"url":valArr2[0]
		}]
	},
	{
		"name":valArr[1],
		"sub_button":[{
			"type":"view",
			"name":valArr1[1],
			"url":valArr2[1]
		}]
	},
	{
		"name":valArr[2],
		"sub_button":[{
			"type":"view",
			"name":valArr1[2] ,
			"url":valArr2[2]
		}]
	}
	]
}
console.log(view);
 })
</script>

</body>
</html>